#include<windows.h>
#include<d3d9.h>
#include<d3dx9.h>
#include<dinput.h> 

#pragma once
#define DIRECTINPUT_VERSION 0x0800

#define D3DFVF_CURSORVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)

struct D3DCURSORVERTEX
{
	float fX,
	fY,
	fZ,
	fRHW;
	DWORD dwColor;
	float fU, fV;
};
class input
{
public:
	input(IDirect3DDevice9 *d3ddev, HWND hWnd);
	bool initInput();
	bool initKeyboard(HWND hWnd);
	bool kpressed(int key);
	bool update();
	~input();

	long getX() { return m_x; };
	long getY() { return m_y; };

	bool InitMouse(HWND hWnd);
	void DrawCursor(void);
	void SetCursor(const char*, int, int, DWORD);
	void SetAttributes(bool, float);
	void SetCursorPosition(float, float);
	long GetXDelta()    { return m_MouseState.lX; }
	long GetYDelta()    { return m_MouseState.lY; }
	long GetZDelta()    { return m_MouseState.lZ; }
	bool  MouseButtonDown(int);

private:
	LPDIRECTINPUT8       m_pDIObject;           
	LPDIRECTINPUTDEVICE8 m_pDIKeyboardDevice;  
	LPDIRECTINPUTDEVICE8 m_pDIMouseDevice;      

	char                 m_KeyBuffer[256];      

	LPDIRECT3DTEXTURE9   m_pCursorTexture;      
	DIMOUSESTATE2        m_MouseState;
	bool                 m_bInverted;          
	float                m_fSensitivity,        
		m_fCursorX,          
		m_fCursorY;
	int                  m_iHotSpotX,           
		m_iHotSpotY;
	DWORD                m_dwAxes,             
		m_dwButtons,           
		m_dwCursorColor,      
		m_dwScreenWidth,       
		m_dwScreenHeight;     

private:
	LPDIRECTINPUT8 m_Input;
	LPDIRECTINPUTDEVICE8 m_KeyInputDev;
	long m_x;
	long m_y;
	char Keybuf[256];
	HWND m_hWnd;
};

